<%@page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

	<title>预算编制</title>
		<%@ include file="../../common/common.jsp"%>
	
<script type="text/javascript">

function pro_statusFormatter(value,row,index){
	if (value==0){
		var s = '未编制';
		return s;
	}
	if (value==1){
		var s = '已编制';
		return s;
	}
	if (value==2){
		var s = '已审核';
		return s;
	}
}


function pro_rowStyler(value,row){
	if (row.projectStatus==0){
		return 'background-color:yellow;color:blue;font-weight:bold;';
	}
}


function statusFormatter(value,row,index){
	if (value==1){
		var s = '<a href="#" onclick="_bz('+row.id+','+row.projectinfo_id+')">已编制</a> ';
		return s;
	} else {
		var e = '<a href="#" onclick="_bz('+row.id+','+row.projectinfo_id+')">未编制</a> ';
		return e;
	}
}

function _bz(projectWorkInfo_id,projectId){
	$('#projectWorkInfoId').attr('value',projectWorkInfo_id);
	$('#projectId').attr('value',projectId);
	_open_bz_page ();	
}




$(function(){
			$('#dg').datagrid({
				view: detailview,
				detailFormatter:function(index,row){
					return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>';
				},
				onExpandRow: function(index,row){
					
					$('#ddv-'+index).datagrid({
						url:'<%=basePath%>loadProWorkDetailAction.do?projectWorkInfo.projectinfo_id='+row.id,
						fitColumns:true,
						singleSelect:true,
						width:'600',
						height:'auto',
						rowStyler:function(index,row){
							if (row.workInfoStatus==0){
								return 'background-color:pink;color:blue;font-weight:bold;';
							}
						},
						columns:[[
							{field:'cesspoolNo',title:'化粪池编号',width:30},
							{field:'cesspoolType',title:'类型',width:20},
							{field:'cesspoolDoPerson',title:'施工分队',width:30},
							{field:'cesspoolBudgetPrice',title:'预算价',width:30},
							{field:'cesspoolDoContent',title:'工程内容',width:50},
							{field:'workInfoStatus',title:'状态',width:30,formatter:statusFormatter}
						]],
						onResize:function(){
							$('#dg').datagrid('fixDetailRowHeight',index);
						},
						onLoadSuccess:function(){
							setTimeout(function(){
								$('#dg').datagrid('fixDetailRowHeight',index);
							},0);
						},
						onClickRow:function(rowIndex,rowData){
							//alert('id:'+rowData.id);
							//$('#projectWorkInfoId').attr('value',rowData.id);
							//_open_bz_page ();
							
						}
					});
					$('#dg').datagrid('fixDetailRowHeight',index);
				}
			});
});
	

		
//打开编辑页面		
function _open_bz_page () {
	var url = "open_budget_do.jsp";
$('<div><iframe frameborder="0" scrolling="no" marginheight="0" framespacing=0 marginwidth="0" '+
		'"FrameBorder=0 src="'+url+'" style="width:100%;height:95%; "/></div>').dialog({			
			open : function() {
			},
			height : 480,
			width : 750,
			title : '编制'
		});
	}
		
		

</script>
</head>
<body>
	
	<input type="hidden" name="projectWorkInfoId" id="projectWorkInfoId">
	<input type="hidden" name="projectId" id="projectId">

	<table id="dg" style="width:1130px;height:420px"
			url="<%=basePath %>loadProjectInfoAction.do" 
			title="项目信息"
			singleSelect="true" fitColumns="true" pagination = "true" rowStyler="pro_rowStyler">
		<thead>
			<tr>
				<th field="contractinfo_name" width="40" align="center" >合同名称</th>
				<th field="projectName" align="center" width="40">项目名称</th>
				<th field="constructionOrganization" align="center" width="20">施工单位</th>
				<th field="pipeLength" width="15" >管道长度</th>
				<th field="managerCompanyInfo" width="20" align="center">物管信息</th>
				<th field="residentCount" width="12" align="center">总户数</th>
				<th field="buildArea" width="12" align="center">总面积</th>
				<th field="pitCount" width="15" align="center">化粪池数</th>
				<th field="budgetPrice" width="18" align="center">项目预算</th>			
				<th field="createTime" width="20" align="center">创建时间</th>
				<th field="projectStatus" width="13" align="center" formatter="pro_statusFormatter" >状态</th>
				<th field="projectSpec" width="40" align="center">项目说明</th>
			</tr>
		</thead>
	</table>
		
</body>
</html>